import RabbmitProducer from '../utils/rabbmitProducer'

import { tags, request, summary, description, prefix, query } from 'koa-swagger-decorator'


const tag = tags(['Rabbmit'])

@prefix("/rabbmit")
export default class RabbmitController {

  @request("post", "/send")
  @summary("发送消息")
  @description("发送消息")
  @tag
  async send (ctx) {
    const { msg } = ctx.request.body;
    RabbmitProducer.sendToWorker(ctx.request.body, 0);
    ctx.success(msg, '发送成功');
  }

  @request("post", "/send-later")
  @summary("发送消息")
  @description("发送消息")
  @tag
  async sendLater (ctx) {
    const { msg } = ctx.request.body;
    console.log('msg', ctx.request.body)
    RabbmitProducer.sendToWorkerLater(ctx.request.body, 0, 5000);
    ctx.success(msg, '延迟发送成功');
  }
}

